package com.baiyi.cloud.platform.tools.controller;

import java.util.Map;

import com.baiyi.cloud.platform.commons.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.access.prepost.PreAuthorize;

import com.baiyi.cloud.platform.tools.model.SysDictData;
import com.baiyi.cloud.platform.tools.service.SysDictDataService;

import com.baiyi.cloud.platform.commons.PageResult;

/**
 * 字典数据表
 *
 * @author huwenfeng
 * @email hwf@imlaidian.com
 * @date 2019-01-14 11:55:23
 */
@RestController
@RequestMapping("sysdictdata")
@Api(tags = "字典数据表")
public class SysDictDataController {

    @Autowired
    private SysDictDataService sysDictDataService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @PreAuthorize("hasAnyAuthority('tools:sysdictdata:list')")
    public PageResult<?> list(@RequestParam Map<String, Object> params){
        PageResult<?> pageResult = sysDictDataService.findAll(params);
        return pageResult;
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    @PreAuthorize("hasAnyAuthority('tools:sysdictdata:save')")
    public Result save(@RequestBody SysDictData sysDictData){
			sysDictDataService.save(sysDictData);

        return Result.succeed("");
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @PreAuthorize("hasAnyAuthority('tools:sysdictdata:update')")
    public Result update(@RequestBody SysDictData sysDictData){
			sysDictDataService.update(sysDictData);

        return Result.succeed("");
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @PreAuthorize("hasAnyAuthority('tools:sysdictdata:delete')")
    public Result delete(@RequestBody Long dictCode){
			sysDictDataService.delete(dictCode);
        return Result.succeed("");
    }

}
